import kyo.VtMenu;
import kyo.ItemRun;
import kyo.RunState;
import kyo.Item;

public class VtMenuTest {
    static public void main(String [] args) {
        VtMenu<String, Object> m = new VtMenu<String, Object>("===== 一级菜单 ====");
        m.setRun(new ItemRun() {
            public <String, Object> RunState run(
                                Item<String, Object> item) {
                switch (item.getId()) {
                    case 1:
                        System.out.printf("11111111\n");
                        break;
                    case 2:
                        System.out.printf("22222222\n");
                        break;
                    case 3:
                        System.out.printf("44444444\n");
                        break;
                }
                return RunState.RUNNING;
            }
        });
        m.add("三角形!");
        m.add("五角形!");
        m.add("六角形!");

        VtMenu<String, Object> s = new VtMenu<String, Object>("---- 二级子菜单 ----");
        s.setRun(new ItemRun() {
            public <String, Object> RunState run(
                                Item<String, Object> item) {
                switch (item.getId()) {
                    case 1:
                        System.out.printf("Sub 11111111\n");
                        break;
                    case 2:
                        System.out.printf("Sub 22222222\n");
                        break;
                    case 3:
                        System.out.printf("Sub 44444444\n");
                        break;
                    case 4:
                        return RunState.RETURN;
                    case 5:
                        return RunState.QUIT;
                }
                return RunState.RUNNING;
            }
        });

        m.add(new Item<String, Object>("子菜单三角形", s));

        s.add("直角三角形!");
        s.add("等腰三角形!");
        s.add("等边三角形!");
        s.add("返回上一级!");
        s.add("退出程序!");

        VtMenu<String, Object> t = new VtMenu<String, Object>("---- 三级子菜单 ----");
        t.setRun(new ItemRun() {
            public <String, Object> RunState run(
                                Item<String, Object> item) {
                switch (item.getId()) {
                    case 1:
                        System.out.printf("Sub Sub 11111111\n");
                        break;
                    case 2:
                        System.out.printf("Sub Sub 22222222\n");
                        break;
                    case 3:
                        System.out.printf("Sub Sub 44444444\n");
                        break;
                    case 4:
                        return RunState.RETURN;
                    case 5:
                        return RunState.QUIT;
                }
                return RunState.RUNNING;
            }
        });

        t.add("111111");
        t.add("222222");
        t.add("333333");
        t.add("return");
        t.add("quit");
        s.add(new Item<String, Object>("子菜单三角形", t));

        m.run();
    }
}
